"use strict";

const Validator = require("../utils/validator");

const rules = {
  id: "int",
  name: "[string]?", // 字符串类型
  sex: "[0|1|2]?", // 枚举类型
  endTime: "datetime",
  endDt: "date?",
  other: "?", // 可选任意值
  emplid: { required: false, type: "string", isArray: true, rename: "userId" },
};

const data = {
  id: "1",
  sex: [1, 2],
  endTime: "2020-05-02 12:01:04",
  // endDt: "1991",
  emplid: ["ada"],
};

try {
  const params = new Validator().validate(rules, data, false);
  console.log(params);
} catch (error) {
  console.log(error);
}
